﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbSymbolTableIterator : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbSymbolTableIterator(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbSymbolTableIterator_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbSymbolTableIterator obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbSymbolTableIterator()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbSymbolTableIterator(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbSymbolTableIterator cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSymbolTableIterator_cast(OdRxObject.getCPtr(pObj));
			OdDbSymbolTableIterator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSymbolTableIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSymbolTableIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSymbolTableIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSymbolTableIterator_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSymbolTableIterator_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbSymbolTableIterator_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbSymbolTableIterator createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSymbolTableIterator_createObject();
			OdDbSymbolTableIterator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSymbolTableIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSymbolTableIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSymbolTableIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void start(bool atBeginning, bool skipErased)
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_start__SWIG_0(this.swigCPtr, atBeginning, skipErased);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void start(bool atBeginning)
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_start__SWIG_1(this.swigCPtr, atBeginning);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void start()
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_start__SWIG_2(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool done()
		{
			bool result = TD_DbPINVOKE.OdDbSymbolTableIterator_done(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbObjectId getRecordId()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbSymbolTableIterator_getRecordId(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbSymbolTableRecord getRecord(OpenMode openMode, bool openErasedRecord)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSymbolTableIterator_getRecord__SWIG_0(this.swigCPtr, (int)openMode, openErasedRecord);
			OdDbSymbolTableRecord result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbSymbolTableRecord getRecord(OpenMode openMode)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSymbolTableIterator_getRecord__SWIG_1(this.swigCPtr, (int)openMode);
			OdDbSymbolTableRecord result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbSymbolTableRecord getRecord()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbSymbolTableIterator_getRecord__SWIG_2(this.swigCPtr);
			OdDbSymbolTableRecord result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSymbolTableRecord)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void step(bool forward, bool skipErased)
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_step__SWIG_0(this.swigCPtr, forward, skipErased);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void step(bool forward)
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_step__SWIG_1(this.swigCPtr, forward);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void step()
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_step__SWIG_2(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void seek(OdDbObjectId ObjectId)
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_seek__SWIG_0(this.swigCPtr, OdDbObjectId.getCPtr(ObjectId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void seek(OdDbSymbolTableRecord pRecord)
		{
			TD_DbPINVOKE.OdDbSymbolTableIterator_seek__SWIG_1(this.swigCPtr, OdDbSymbolTableRecord.getCPtr(pRecord));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
